package com.south.base.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 * @date 2019/5/24 17:41
 */
@Aspect
@Slf4j
@Component
public class ServiceAspect {
    @Pointcut("execution (* com.south.base.service.HelloWorldAspectService.*(..))")
    public void pointcut() {

    }

    @Before("pointcut()")
    public void before() {
        log.info("service before");
    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        log.info("service around before");
        Object o = pjp.proceed();
        log.info("service around after");
        return o;
    }

    @After("pointcut()")
    public void after() {
        log.info("service after");
    }

    @AfterReturning("pointcut()")
    public void afterReturning() {
        log.info("service after returning");
    }

    @AfterThrowing(throwing = "ex",pointcut = "pointcut()")
    public void afterThrowing(Throwable ex) {
        log.info("service after throwing");
    }
}
